package com.xds.springcloud.controller;

import com.xds.springcloud.service.PaymentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author Bai Xu
 * @Date 2021/9/30 9:37
 * @Version 1.0
 */
@RestController
@Slf4j
@RequestMapping("/payment")
public class PaymentController {
    @Autowired
    private PaymentService paymentService;
    @Value("${server.port}")
    private String serverPort;
    @GetMapping("hystrix/ok/{id}")
    public String paymentInfo_ok(@PathVariable("id") Integer id){
        String result=paymentService.paymentInfo(id);
        log.info("result========>"+result);
        return result;
    }
    @GetMapping("hystrix/timeOut/{id}")
    public String timeOut(@PathVariable("id") Integer id){
        String result=paymentService.TimeOut(id);
        log.info("result========>"+result);
        return result;
    }
    //---------------服务熔断----------------------------
    @GetMapping("hystrix/circuit/{id}")
    public String paymentCircuitBreak(@PathVariable("id") Integer id){
        String result=paymentService.paymentCircuitBreaker(id);
        log.info("result========>"+result);
        return result;
    }

}
